﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;
using DevExpress.XtraGrid.Views.Grid;
using QuanLyKho.QuanLyKho;

namespace QuanLyKho.Control
{
    public partial class Kho_Loaivattu : UserControl
    {
        public Kho_Loaivattu()
        {
            InitializeComponent();
            LoadData();
        }

        public void LoadData()
        {
            gridLoaiVatTu.DataSource = DataAll.SelectAll("Kho_LoaiVatTu", "*", "");
            SetPropertiesGrid();
        }

        public void SetPropertiesGrid()
        {
            //gvLoaiVatTu.FocusRectStyle = DrawFocusRectStyle.RowFullFocus;
            //gvLoaiVatTu.OptionsBehavior.Editable = false;
            //gvLoaiVatTu.OptionsSelection.EnableAppearanceFocusedCell = false;
            //gvLoaiVatTu.OptionsSelection.MultiSelect = true;
            //gvLoaiVatTu.OptionsView.ShowGroupPanel = false;
            //gvLoaiVatTu.OptionsView.ColumnAutoWidth = true;
            //gvLoaiVatTu.OptionsView.ShowFooter = true;
            //gvLoaiVatTu.OptionsFind.AlwaysVisible = true;
            gvLoaiVatTu.Columns["IDLoaiVatTu"].Visible = false;
        }

        private void bntThemMoi_Click(object sender, EventArgs e)
        {
            Kho_Themloaivattu themloaivattu = new Kho_Themloaivattu();
            themloaivattu.ShowDialog();
            LoadData();
        }

        private void gvLoaiVatTu_DoubleClick(object sender, EventArgs e)
        {
            if (gvLoaiVatTu.FocusedRowHandle >= 0)
            {
                Kho_Themloaivattu.MaID = gvLoaiVatTu.Columns["IDLoaiVatTu"].View.GetRowCellDisplayText(gvLoaiVatTu.FocusedRowHandle, "IDLoaiVatTu");
                var themlvt = new Kho_Themloaivattu();
                themlvt.ShowDialog();
                LoadData();
                Kho_Themloaivattu.MaID = "0";
            } 
        }
    }
}
